package com.bilibili.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bilibili.entity.CommenResult;
import com.bilibili.entity.User;
import com.bilibili.entity.Video;
import com.bilibili.service.WatchHisoryService;
import com.bilibili.service.impl.WatchHisoryServiceImpl;


@WebServlet("/watchHisory.do")
public class WatchHisoryServlet extends HttpServlet {
	WatchHisoryService ws = new WatchHisoryServiceImpl();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("application/json;charset=utf-8");
        List<Video> list = ws.SelectByUpId(((User)request.getSession().getAttribute("loginUser")).getUserId());
        User user = (User)request.getSession().getAttribute("loginUser");
        List<Object> all = new ArrayList<Object>();
        all.add(list);
        all.add(user);
        CommenResult result = new CommenResult();
        result.setData(all);
        response.getWriter().write(result.toJOSNString());
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
